
//TODO a(18)
function a18(module, exports) {
    function a(e, t, a) {
        (e || "").split(l).forEach(function (e) {
            a(e, t)
        })
    }


    function i(e) {
        return new RegExp("(?:^| )" + e.replace(" ", " .* ?") + "(?: |$)")
    }

    function s(e) {
        var t = ("" + e).split(".");
        return {e: t[0], ns: t.slice(1).sort().join(" ")}
    }

    function r(e, t, a, r) {
        var n, o;
        return o = s(t), o.ns && (n = i(o.ns)), e.filter(function (e) {
            return e && (!o.e || e.e === o.e) && (!o.ns || n.test(e.ns)) && (!a || e.cb === a || e.cb._cb === a) && (!r || e.ctx === r)
        })
    }

    function n(e, t) {
        return this instanceof n ? (t && $.extend(this, t), this.type = e, this) : new n(e, t)
    }

    var o = [].slice, l = /\s+/, d = function () {
        return !1
    }, h = function () {
        return !0
    };
    n.prototype = {
        isDefaultPrevented: d, isPropagationStopped: d, preventDefault: function () {
            this.isDefaultPrevented = h
        }, stopPropagation: function () {
            this.isPropagationStopped = h
        }
    };
    var c = {
        on: function (e, t, i) {
            var r, n = this;
            return t ? (r = this._events || (this._events = []), a(e, t, function (e, t) {
                    var a = s(e);
                    a.cb = t, a.ctx = i, a.ctx2 = i || n, a.id = r.length, r.push(a)
                }), this) : this
        }, one: function (e, t, i) {
            var s = this;
            return t ? (a(e, t, function (e, t) {
                    var a = function () {
                        return s.off(e, a), t.apply(i || s, arguments)
                    };
                    a._cb = t, s.on(e, a, i)
                }), this) : this
        }, off: function (e, t, i) {
            var s = this._events;
            return s ? e || t || i ? (a(e, t, function (e, t) {
                        r(s, e, t, i).forEach(function (e) {
                            delete s[e.id]
                        })
                    }), this) : (this._events = [], this) : this
        }, trigger: function (e) {
            var t, a, i, s, l, d = -1;
            if (!this._events || !e)return this;
            if ("string" == typeof e && (e = new n(e)), t = o.call(arguments, 1), e.args = t, a = r(this._events, e.type))for (s = a.length; ++d < s;)if ((i = e.isPropagationStopped()) || !1 === (l = a[d]).cb.call(l.ctx2, e)) {
                i || (e.stopPropagation(), e.preventDefault());
                break
            }
            return this
        }
    };
    module.exports = c
}
